package com.lanyou.esb.cook.proxy.entity;

import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.lanyou.esb.cook.proxy.common.Constants;
import com.lanyou.esb.cook.proxy.meta.EnableType;

/**
 * 平台吞吐量表
 * 
 * @author Davey.wu
 */
public class PfThroughput {
	/** 领域信息表ID **/
	private String fieldId;
	/** 统计时间 **/
	private Date statisticsDate;
	/** 吞吐量 **/
	private double throughputQty;
	/** 是否可用 **/
	private String isEnable;
	/** 创建人 **/
	private String creator;
	/** 创建时间 **/
	private Date createDate;
	/** 最后更新人员 **/
	private String modifier;
	/** 最后更新时间 **/
	private Date lastUpdatedDate;

	public PfThroughput() {
		this.isEnable = EnableType.ENABLE.ValueCode;
		this.creator = Constants.DEFAULT_USER;
	}

	public void incQty(double qty) {
		this.throughputQty += qty;
	}

	public String getFieldId() {
		return fieldId;
	}

	public PfThroughput setFieldId(String fieldId) {
		this.fieldId = fieldId;
		return this;
	}

	public Date getStatisticsDate() {
		return statisticsDate;
	}

	public PfThroughput setStatisticsDate(Date statisticsDate) {
		if (statisticsDate != null) {
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(statisticsDate);
			calendar.set(Calendar.HOUR_OF_DAY, 0);
			calendar.set(Calendar.MINUTE, 0);
			calendar.set(Calendar.SECOND, 0);
			calendar.set(Calendar.MILLISECOND, 0);
			this.statisticsDate = calendar.getTime();
			return this;
		}
		this.statisticsDate = statisticsDate;
		return this;
	}

	public double getThroughputQty() {
		return throughputQty;
	}

	public PfThroughput setThroughputQty(double throughputQty) {
		this.throughputQty = throughputQty;
		return this;
	}

	public String getIsEnable() {
		return isEnable;
	}

	public PfThroughput setIsEnable(String isEnable) {
		this.isEnable = isEnable;
		return this;
	}

	public String getCreator() {
		return StringUtils.isEmpty(creator) ? Constants.DEFAULT_USER : creator;
	}

	public PfThroughput setCreator(String creator) {
		this.creator = creator;
		return this;
	}

	public Date getCreateDate() {
		return createDate == null ? new Date() : createDate;
	}

	public PfThroughput setCreateDate(Date createDate) {
		this.createDate = createDate;
		return this;
	}

	public String getModifier() {
		return StringUtils.isEmpty(modifier) ? Constants.DEFAULT_USER
				: modifier;
	}

	public PfThroughput setModifier(String modifier) {
		this.modifier = modifier;
		return this;
	}

	public Date getLastUpdatedDate() {
		return lastUpdatedDate;
	}

	public PfThroughput setLastUpdatedDate(Date lastUpdatedDate) {
		this.lastUpdatedDate = lastUpdatedDate;
		return this;
	}

}